package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 员工业绩奖罚
 *
 * @author Jason
 */
@Entity
@Table(name = "tnb_employee_proformance")
@JsonApiResource(type = "employeeproformance")
public class EmployeeProformance extends BaseEntity {
	
	private String typeName;// 绩效名称
	
	private String typeItemName;// 绩效细则ID
	
	private Dicttype type;	// 奖罚类型 奖励/罚款
	
	private Employee employee;	// 奖罚员工
	
	private SalaryPosition salaryPosition;	// 职位
	
	private User createUser; // 创建人
	
	private User lastUpdateUser;// 更新操作者userid
	
	private Double amount;	// 奖罚金额
	
	private Integer createTime;
	
	private String remark;
	
	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "employee_id")
	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "type")
	public Dicttype getType() {
		return type;
	}

	public void setType(Dicttype type) {
		this.type = type;
	}

	public Integer getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Integer createTime) {
		this.createTime = createTime;
	}

	@Column(name="amount", columnDefinition="double default 0", nullable=false)
	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "salaryposition_id")
	public SalaryPosition getSalaryPosition() {
		return salaryPosition;
	}

	public void setSalaryPosition(SalaryPosition salaryPosition) {
		this.salaryPosition = salaryPosition;
	}

	@Column(name = "typeName")
	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}
	
	@Column(name = "typeItemName")
	public String getTypeItemName() {
		return typeItemName;
	}
	
	public void setTypeItemName(String typeItemName) {
		this.typeItemName= typeItemName;
	}
	
	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}
	
	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

}
